package aom.ju.ss.view.dialog

import android.app.Activity
import android.app.Dialog
import android.view.Gravity
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import aom.ju.ss.R
import aom.ju.ss.databinding.PicCarmDialogBinding
import aom.ju.ss.lpInterface.TitleDialogInterface

/**
 * 选择 上传方式
 */
class PicCameraDialog(activity: Activity, dialogInterface: TitleDialogInterface) {


    var vBinding: PicCarmDialogBinding? = null

    var dialog: Dialog? = null

    init {
        dialog = Dialog(activity, R.style.dialogBoom)


        vBinding = DataBindingUtil.inflate<ViewDataBinding>(
            LayoutInflater.from(activity),
            R.layout.pic_carm_dialog,
            null,
            false
        ) as PicCarmDialogBinding?
        vBinding?.root?.let { dialog?.setContentView(it) }

        val layoutParams = dialog?.window!!.attributes
        layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
        layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT
        layoutParams.gravity = Gravity.BOTTOM
        dialog?.window!!.attributes = layoutParams
        dialog?.setCanceledOnTouchOutside(false)

        dialog?.show()

        vBinding?.ok?.setOnClickListener {

            dialog?.dismiss()
        }
        vBinding?.cam?.setOnClickListener {
            dialogInterface.ok(it, true)
            dialog?.dismiss()
        }
        vBinding?.pic?.setOnClickListener {
            dialogInterface.ok(it, false)
            dialog?.dismiss()
        }
    }


}